﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Net;
using System.Xml.Linq;

namespace Grid
{
    public partial class Page : UserControl
    {
        public Page()
        {
            InitializeComponent();
            
            WebClient client = new WebClient(); Uri uri =
   new Uri("http://feeds.reuters.com/reuters/topNews?format=xml");
            client.DownloadStringCompleted +=
               new DownloadStringCompletedEventHandler(
                    client_DownloadStringCompleted);
            client.DownloadStringAsync(uri);
            
        }
        void client_DownloadStringCompleted(
  object sender, DownloadStringCompletedEventArgs e)
        {
            XDocument xmlHeadlines = XDocument.Parse(e.Result);
            var headlines = from story in xmlHeadlines.Descendants("item")
                            select new NewsHeadLine
                            {
                                strHead = (string)story.Element("title"),
                                strLine = (string)story.Element("link")
                            };
            GrdHeadline.ItemsSource = headlines;
        }

    }
}
public class NewsHeadLine
{
    public string strHead { get; set; }
    public string strLine { get; set; }
}
